#!/bin/bash

if [ $# -lt 2 ]; then
  echo "$0 <repo file> <pattern>"
  exit 0
fi

repo=$1
pkg=$2

yum -c ${repo} --disablerepo=\* --enablerepo=everything --enablerepo=everything-sp1 provides ${pkg} | grep '^Provide' -B4 | sed -n '2p' \
| awk -F':' '{print $1}' \
| while read i;
do
  ./dl.sh ${repo} "$i"
done
